<?php

namespace app\admin\model;

use think\Model;

class Article extends Model
{
    public function setContentAttr($value,$data){
        if($value){
            $value=htmlspecialchars($value);
        }
        return $value;
    }
    public function getContentAttr($value,$data){
        if($value){
            $value=htmlspecialchars_decode($value);
        }
        return $value;
    }
    public function getRecommendsNameAttr($value,$data){
        if(!empty($data['recommends'])){
            $recommends_name = Classify::where('id',$data['recommends'])->value('title');
        }else{
            $recommends_name = '';
        }
        return $recommends_name;
    }
    public function getAdminIdNameAttr($value,$data){
        if(!empty($data['admin_id'])){
            $admin_name = Admin::where('id',$data['admin_id'])->value('truename');
        }else{
            $admin_name = '';
        }
        return $admin_name;
    }
}
